package com.redhat.auth.web.securitystrategy;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.redhat.auth.application.SecurityStrategyApplication;
import com.redhat.auth.domain.SecurityStrategy;
import com.redhat.redwork.coc.RedworkAction;
import com.redhat.redwork.coc.RedworkActionSupport;

/**
 * 安全策略
 * @author Justin
 *
 */
public class SecurityStrategyAction extends RedworkActionSupport implements RedworkAction{

	private static final long serialVersionUID = 1228500544434752440L;
	
	@NotNull
	@Valid
	SecurityStrategy strategy;
	
	SecurityStrategyApplication securityStrategyApplication;
	
	public void setSecurityStrategyApplication(
			SecurityStrategyApplication securityStrategyApplication) {
		this.securityStrategyApplication = securityStrategyApplication;
	}

	public SecurityStrategy getStrategy() {
		return strategy;
	}

	public void setStrategy(SecurityStrategy strategy) {
		this.strategy = strategy;
	}

	public String management(){
		strategy = securityStrategyApplication.loadSecurityStrategy();
		return "management";
	}
	
	/**
	 * 保存安全策略设置
	 * @return
	 */
	public String save(){
		securityStrategyApplication.saveSecurityStrategy(strategy);
		return "management";
	}
	
	public String demo(){
		return "json";
	}
}
